package Login_02;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Register extends HttpServlet{
    public static List<User> list = new ArrayList<>();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("Utf-8");
        //获取用户输入的信息
        String uname = req.getParameter("userName");
        String pwd = req.getParameter("pwd");
        System.out.println(uname+pwd);
        //封装成对象
        User user = new User(uname,pwd);
        list.add(user);
        System.out.println(list);
        //注册成功之后跳转登录
        resp.sendRedirect("index.jsp");
    }
}
